package hzn.service.impl;

import bean.UserAddress;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.stereotype.Component;
import service.UserService;

import java.util.Arrays;
import java.util.List;

//@Service//是dubbo的注解，目的是为了暴露服务
//@Service(version = "2.0")
//@Component
public class UserServiceImpl_2 implements UserService {
    @Override
    public UserAddress getUserAddress(String userId) {
        System.out.println("this is version 2.0");
        try {
            Thread.sleep(0);
        } catch (InterruptedException e) { }
        UserAddress a1=new UserAddress(1,"南京","1","孙武","138987","Y");
        UserAddress a2=new UserAddress(2,"北京","2","吴起","1309777","N");
        List<UserAddress>list= Arrays.asList(a1,a2);
        for(int i=0;i<list.size();i++){
            if(list.get(i).getUserId().equals(userId)){
                return list.get(i);
            }
        }
        return null;
    }
}
